package com.buaa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.buaa.dto.TrafficIncidentDTO;
import com.buaa.entity.TrafficIncident;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TrafficIncidentMapper extends BaseMapper<TrafficIncident> {

    @Select("select sum(open_incident) as openIncident from traffic_incident where incident_city='北京市' ")
    long getOpenCase();

    @Select("select sum(closed_incident) as closedIncident from traffic_incident where incident_city='北京市' ")
    long getClosedCase();

    @Select("select DATE_FORMAT(month,'%Y-%m') AS month, sum(closed_incident) as  closed_incident, sum(open_incident) as open_incident from traffic_incident\n" +
            "group by month order by 1 asc")
    List<TrafficIncidentDTO> getIncidentByMonth();
}
